const usersParams = (mongoose) => {
  const { Schema, model } = mongoose
  // 通用 用户表
  const commonSchema = {
    password: {
      type: String,
      required: true,
    },
    phoneNo: {
      type: String,
      required: true,
    },
    userNo: {
      type: Number,
      required: true,
    },
    avatars: {
      type: String,
    },
    roleName: {
      type: String,
    },
    userName: {
      type: String,
    },
    roleNo: {
      type: Number,
    },
    hashPhone: {
      type: String,
    },
  }

  // 管理平台 用户表
  const adminSchema = {
    ...commonSchema,
    routes: {
      type: Array,
    },
  }

  // 小程序 用户表
  const wechatSchema = {
    ...commonSchema,
    loginCount: {
      type: Number,
    },
    address: {
      type: Array,
    },
  }

  const adminUser = new Schema(adminSchema, {
    timestamps: true,
  })

  const wechatUser = new Schema(wechatSchema, {
    timestamps: true,
  })

  const adminUsers = model('admin_user_manage', adminUser)
  const wechatUsers = model('wechat_user_manage', wechatUser)

  return {
    wechatUsers,
    adminUsers,
  }
}

module.exports = usersParams
